package baiqitun.stupro.security.service.impl;

import baiqitun.stupro.common.service.support.MyServiceImpl;
import baiqitun.stupro.security.entity.SysRole;
import baiqitun.stupro.security.mapper.SysRoleMapper;
import baiqitun.stupro.security.service.SysRoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author kedaji
 * @since 2020-03-25
 */
@Service
public class SysRoleServiceImpl extends MyServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

    @Cacheable("role")
    @Transactional(readOnly = true, rollbackFor = Exception.class)
    @Override
    public SysRole getRoleByCode(String roleCode) {
        SysRole queryRole = new SysRole();
        queryRole.setCode(roleCode);
        return getOne(new QueryWrapper<>(queryRole));
    }
}
